VERSION 5.00
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
Begin VB.Form frmMain 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "Winamp Playlist Copier <alias.zero2097@gmail.com>"
   ClientHeight    =   3495
   ClientLeft      =   45
   ClientTop       =   375
   ClientWidth     =   5235
   Icon            =   "frmMain.frx":0000
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   3495
   ScaleWidth      =   5235
   StartUpPosition =   3  'Windows Default
   Begin VB.ListBox lstStatus 
      Height          =   645
      Left            =   120
      TabIndex        =   6
      Top             =   2760
      Width           =   4935
   End
   Begin VB.CommandButton cmdCopy 
      Caption         =   "Copy Playlist to Folder"
      Height          =   495
      Left            =   2880
      TabIndex        =   5
      Top             =   2160
      Width           =   2175
   End
   Begin VB.TextBox txtDest 
      Height          =   285
      Left            =   120
      TabIndex        =   4
      Text            =   "C:\PlaylistTemp\"
      Top             =   1800
      Width           =   4935
   End
   Begin VB.CommandButton cmdBrowse 
      Caption         =   "Browse"
      Height          =   495
      Left            =   3840
      TabIndex        =   2
      Top             =   840
      Width           =   1215
   End
   Begin VB.TextBox txtPlayList 
      Height          =   285
      Left            =   120
      TabIndex        =   1
      Top             =   480
      Width           =   4935
   End
   Begin MSComDlg.CommonDialog CommonDialog1 
      Left            =   1920
      Top             =   1560
      _ExtentX        =   847
      _ExtentY        =   847
      _Version        =   393216
   End
   Begin VB.Label Label1 
      Caption         =   "Status:"
      Height          =   255
      Left            =   120
      TabIndex        =   7
      Top             =   2400
      Width           =   1695
   End
   Begin VB.Label lblDestination 
      Caption         =   "Destination Folder (Type it ya lazy bum):"
      Height          =   255
      Left            =   120
      TabIndex        =   3
      Top             =   1440
      Width           =   4215
   End
   Begin VB.Label lblPlayList 
      Caption         =   "Playlist File:"
      Height          =   255
      Left            =   120
      TabIndex        =   0
      Top             =   120
      Width           =   4215
   End
End
Attribute VB_Name = "frmMain"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub cmdBrowse_Click()
    CommonDialog1.Filter = "*.m3u|*.m3u"
    CommonDialog1.ShowOpen
    If Len(CommonDialog1.FileName) > 2 Then txtPlayList.Text = CommonDialog1.FileName
End Sub

Private Sub cmdCopy_Click()
On Error Resume Next
    If Right(txtDest.Text, 1) <> "\" Then txtDest.Text = txtDest.Text & "\"
    MkDir txtDest.Text
    
    Dim scurrent As String
    Dim hashthingy As String
    Dim FileName() As String
    Dim PlayListFileName() As String
    Dim PlayListPath As String
    
    If Dir(txtPlayList.Text) <> "" And txtPlayList.Text <> "" Then
        cmdCopy.Enabled = False
        txtDest.Locked = True
        txtPlayList.Locked = True
        Open txtDest.Text & "[Playlist].m3u" For Output As #2
        Print #2, "#EXTINF:203,[Generated by Winamp Playlist Copier by Agret]" & vbCrLf & "[Generated by Winamp Playlist Copier by Agret].mp3"
        PlayListFileName() = Split(txtPlayList.Text, "\")
        PlayListPath = Left(txtPlayList.Text, Len(txtPlayList.Text) - Len(PlayListFileName(UBound(PlayListFileName()))) - 1) & "\"
        Debug.Print "****" & "PlayList Path: " & PlayListPath & " ****"
        Open txtPlayList.Text For Input As #1
            Do Until EOF(1)
            Line Input #1, scurrent
            If Left(scurrent, 1) = "\" Then
                scurrent = "C:" & scurrent
            End If
            If Left(scurrent, 1) = "#" Then
                hashthingy = scurrent
            Else
                FileName() = Split(scurrent, "\")
                If UBound(FileName()) = 0 Then
                    scurrent = PlayListPath & scurrent
                End If
                'Debug.Print "***" & UBound(FileName()) & "*** - " & FileName(UBound(FileName()))
                If Mid(scurrent, 2, 1) = ":" Then
                    If Dir(scurrent) <> "" Then
                        AddToLog "Copying " & FileName(UBound(FileName())) & "..."
                        Print #2, hashthingy & vbCrLf & FileName(UBound(FileName()))
                        DoEvents
                        FileCopy scurrent, txtDest.Text & FileName(UBound(FileName()))
                    End If
                End If
            End If
            Loop
        Close #1
        Close #2
        AddToLog "Completed Copying"
        MsgBox "Completed Copying"
        cmdCopy.Enabled = True
        txtDest.Locked = False
        txtPlayList.Locked = False
        Shell "explorer.exe """ & txtDest.Text & """", vbNormalFocus
    Else
        MsgBox "File doesn't exist", vbCritical, "Fail"
    End If
End Sub

Function AddToLog(LogEntry As String)
    lstStatus.AddItem "[" & Hour(Now) & ":" & Minute(Now) & "]" & " " & LogEntry
    lstStatus.ListIndex = lstStatus.ListCount - 1
End Function

Private Sub Form_Load()
    AddToLog "Program Started"
End Sub
